package de.baumann.browser.adapter

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import de.baumann.browser.R
import de.baumann.browser.api.net.vo.PowerDesc

class PowerDescAdapter(private var descs: List<PowerDesc>) : RecyclerView.Adapter<PowerDescAdapter.PowerHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PowerHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_power_desc, parent, false)
        return PowerHolder(view)
    }

    override fun getItemCount(): Int {
        return descs.size
    }

    override fun onBindViewHolder(holder: PowerHolder, position: Int) {
        val desc = descs[position]
        holder.title.text= desc.title
        holder.content.text= desc.desc
    }

    inner class PowerHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var title:TextView = itemView.findViewById(R.id.descTitle)
        var content:TextView = itemView.findViewById(R.id.descContent)
    }
}